package com.city.java.reports.controller;

import com.city.java.base.utils.PageVO;
import com.city.java.reports.pojo.dto.ReportQuery;
import com.city.java.reports.pojo.entity.ReportProcessing;
import com.city.java.reports.pojo.entity.Reports;
import com.city.java.reports.pojo.vo.ReportVO;
import com.city.java.reports.service.ReportService;
import com.city.java.base.response.JsonResult;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 举报信息控制器
 * RestController注解: 组合注解，相当于@Controller + @ResponseBody
 * Api注解: Knife4j文档中模块的显示名称
 * RequestMapping注解: 设置统一的请求路径前缀
 */
@Slf4j
@Api(tags = "07.举报信息模块")
@RestController
@RequestMapping("/api/reports")
public class ReportController {

    @Autowired
    private ReportService reportService;


    /**
     * 查询所有举报信息列表
     */
    @GetMapping("/select")
    @ApiOperation(value = "查询所有举报信息", notes = "查询所有举报信息列表")
    public JsonResult getReports(ReportQuery reportQuery) {
        log.info("接收到查询所有举报信息请求");
        PageVO<ReportVO> pageVO = reportService.select(reportQuery);
        return JsonResult.ok(pageVO);
    }

    /**
     * 根据举报ID删除举报信息
     * DeleteMapping注解: 处理DELETE请求
     */
    @DeleteMapping("/delete/id/{reportId}")
    @ApiOperation(value = "根据ID删除举报信息", notes = "根据举报ID删除举报信息")
    public JsonResult deleteReportById(
            @ApiParam(value = "举报ID", required = true, example = "1")
            @PathVariable Long reportId) {
        log.info("接收到根据ID删除举报信息请求: ID={}", reportId);
        return reportService.deleteReportById(reportId);
    }

    /**
     * 更新举报信息
     * PutMapping注解: 处理PUT请求
     */
    @PutMapping("/update")
    @ApiOperation(value = "更新举报信息", notes = "更新举报信息详细信息")
    public JsonResult updateReport(
            @ApiParam(value = "举报信息", required = true)
            @RequestBody Reports report) {
        log.info("接收到更新举报信息请求: {}", report);
        return reportService.updateReport(report);
    }
}
